

var util = require('util');

var mongojs = require('mongojs');

exports.Test_mongodb_log_pvp_play = mongojs('172.16.3.151/pz_user', ['log_pvp_play']);
exports.Real_mongodb_log_pvp_play = mongojs('172.16.1.193/pz_user', ['log_pvp_play']);

exports.pvpCount = function(req, res){
    var server = req.param('server');
    var seq = Number(req.param('seq'));

    console.log(new Date(2013,1,1));

    var startdate = "2014-03-07";
    var enddate = "2014-04-07";

    var isodate = new Date(-7).toISOString();

    if (server == "Test") {
        var db = req.app.get("test_mongodb_log_pvp_play");

        db.log_pvp_play.find({user_seq: seq, reg_time : { $gte : isodate }}, function(err, docs) {
            console.log(docs);
            res.render('jjaehuny/jjaehuny_test', { title: 'Express', docs:docs });
        });
    }
    else {
        var db = req.app.get("real_mongodb_log_pvp_play");

        db.log_pvp_play.find({user_seq:seq}, function(err, docs) {
            res.render('jjaehuny/jjaehuny_test', { title: 'Express', docs:docs });
        });
    }
};